from visual import *
from random import randint
import constants

ballColors = [  [materials.wood, color.orange],
                [materials.wood, color.blue],
                [materials.rough, color.magenta],
                [materials.marble, color.white],
                [materials.marble, color.green],
                [materials.shiny, color.red],
                [materials.plastic, color.yellow]  ]

def getBallPosition(i, j, k):
    x = (k - 0.5 * (constants.numberOfLines - (i + j) % 2)) * constants.sphereDistance
    y = (j - 0.5 * (constants.numberOfLines - i % 2)) * constants.sphereDistance * constants.sin60
    z = constants.sphereDistance * constants.sin60 * i
    return vector(x, y, z)
#generira pozicije kugli

def getNewBall():
    rand = randint(0, len(ballColors)-1) 
    return sphere(material=ballColors[rand][0], color=ballColors[rand][1], 
                  radius = constants.defaultRadius)
#nova kugla

def getNewBallOnCanon():
    canonBall = getNewBall()
    canonBall.pos = constants.canonStart
    canonBall.opacity = 0.35
    return canonBall
#nova kugla na topu
